<template>
  <div class="page">
    <button @click="handleClick">设备测试</button>

    <div class="device-item" v-for="item in data">
      {{ item }}
    </div>
  </div>
</template>
<script setup>
import { ref } from "vue";
import { startDiscovery } from "@/uni_modules/ble";

const data = ref([]);

const handleClick = () => {
  plus.android.requestPermissions([
    "android.permission.BLUETOOTH",
    "android.permission.BLUETOOTH_ADMIN",
    "android.permission.BLUETOOTH_CONNECT",
    "android.permission.BLUETOOTH_SCAN",
  ]);
  startDiscovery((map) => {
    console.log("map", map);
  });
};

const handleAction = (value) => {
  switch (value) {
    case "connect":
      handleConnect();
      break;
    case "print":
      handlePrint();
      break;
  }
};

function getBluetoothDevices() {
  kuxBluetooth.getBluetoothDevices({
    success: (res) => {
      console.log("res", res);

      data.push(res);
    },
  });
}
</script>
<style lang="scss" scoped>
.page {
  padding: 12px;
}
</style>
